feat(conversation-manager): improve tool result truncation strategy#1756
Conversation
|
@JackYPCOnline Tagging you for review! |
src/strands/agent/conversation_manager/sliding_window_conversation_manager.py
Show resolved
Hide resolved
src/strands/agent/conversation_manager/sliding_window_conversation_manager.py
Show resolved
Hide resolved
src/strands/agent/conversation_manager/sliding_window_conversation_manager.py
Show resolved
Hide resolved
|
Assessment: Comment This PR improves the truncation strategy with a solid implementation that preserves context rather than completely replacing tool results. The test coverage is comprehensive. Review Summary
Good work on maintaining backward compatibility and implementing oldest-first ordering. |
src/strands/agent/conversation_manager/sliding_window_conversation_manager.py
Outdated
Show resolved
Hide resolved
7e9b87d to
1942cf8
Compare
Partially truncate large tool results (preserve first/last 200 chars) instead of replacing with error. Replace image blocks with placeholders, and target oldest tool results first.
1942cf8 to
fb64029
Compare
|
Assessment: Comment Thanks for updating the class docstring! The truncation behavior is now well-documented (lines 26-29). Review StatusAddressed:
Still Open (from previous review threads):
The implementation is solid and test coverage is comprehensive. The configurability question is worth addressing to fully align with #1545's requirements, but could also be a follow-up PR if preferred. |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Description
Improves the
SlidingWindowConversationManagertruncation strategy to reducecontext size more gracefully without misleading the agent.
instead of replacing entire content with an error message
ValueErrorfor invalidper_turnvalues (0 or negative integer)_find_last_message_with_tool_results→_find_oldest_message_with_tool_resultsto accurately reflect iteration order
Related Issues
Closes #1545
Documentation PR
N/A
Type of Change
Other: Enhancement - improve existing truncation behavior
Testing
hatch run prepareAdded unit tests covering partial truncation, image block replacement,
oldest-first ordering, idempotency guard, and boundary conditions.
Checklist